package com.java.jwt.filter.utils.controller;

/**
 * @author cf
 * @date 2021/10/26 9:41
 */
public class UserController {

    /**
     * 用户登陆
     * JPA操作
     *
     * @param data 账号密码
     * @return 用户凭证
     */
//    @ResponseBody
//    @PostMapping("/login/account")
//    public JSONObject login(@RequestBody JSONObject data) {
////        Optional<User> optionalUser = userService.findUserByUsernameAndPassword(data.getString("username"), data.getString("password"));
////        if (optionalUser.isEmpty()) {
////            throw new LoginException("账号密码不匹配");
////        }
////        User user = optionalUser.get();
//
//        //生成token信息----jwtSecret 密钥
////        LocalDate expiresDate = LocalDate.now().plusWeeks(1);
////        //算法
////        Algorithm algorithm = Algorithm.HMAC256(jwtSecret);
////        String token = JWT.create()
////                .withIssuer("isip")
////                .withSubject("user")
////                .withIssuedAt(new Date())
////                .withExpiresAt(Date.from(expiresDate.atStartOfDay().atZone(ZoneId.systemDefault()).toInstant()))
////                .withClaim("uid", user.getId())
////                .withClaim("access", user.getAccess().toString())
////                .sign(algorithm);
////        JSONObject obj = new JSONObject();
////        obj.put("token", token);
////        return obj;
//
//    }
}
